package fr.ssd.ci.ui.action;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

import javax.swing.JFileChooser;
import javax.swing.JTextField;

public class KeyStoreChooserAction implements ActionListener{

	private JFileChooser keyStoreFileChooser;
	private JTextField keyStoreField;
	private Component ui;
	
	public KeyStoreChooserAction(Component ui, JTextField keyStoreField) {
		this.keyStoreField = keyStoreField;
		keyStoreFileChooser = new JFileChooser();	
	}

	public void actionPerformed(ActionEvent e) {
		int returnVal = keyStoreFileChooser.showOpenDialog(ui);

		if (returnVal == JFileChooser.APPROVE_OPTION) {
			File file = keyStoreFileChooser.getSelectedFile();
			keyStoreField.setText(file.getAbsolutePath());
			
		}
		
	}

}
